<?php
include "includes/ui.php";
include_once "controls/student_db2.php";

$type= $_POST['my_t'];
$s_id = $_POST['my'];
$disable="";
if ($type=="o")
	$disable="disabled";
	
echo headerHTML("student","ข้อมูลนักเรียน");

$m_student = new M_StudentDB();
$val = $m_student->loadStudentData($s_id);
?>
<style>
	.medatory{
		color:red;
	}
</style>

 <div id="popupSave" class="modal hide fade" style="width:350px;top:35% !important;margin-left:-180px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">

    <div class="modal-header" style='padding-top:20px;padding-bottom:25px;'>
        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
        <h3 id="myModalLabel" style="color:#72a9c9;"><img src='img/info1.png' width='24px'/> คุณต้องการบันทึกข้อมูล ?</h3>
    </div>
  
    <div class="modal-footer center" style="text-align:center !important;padding-top:15px;padding-bottom:15px;">
        <button type='button'  class="btn btn-primary" id="btnConfirm">ตกลง</button>
        <button class="btn" data-dismiss="modal" aria-hidden="true">ยกเลิก</button>
    </div>
 
</div> 

 	<!-- Alert -->
		<div class="alert">
			<a class="close" data-dismiss="alert"></a>
			<?php if ($type=="o"){ ?>
			<i class="icon-file-alt"></i> ข้อมูลนักเรียน
			<?php }else {?>
			<i class="icon-file-alt"></i> ข้อมูลนักเรียนใหม่
			<?php }?>
		</div>
		<!-- / Alert -->

<!-- Live Stats -->
<div class="row-fluid">

    <!-- Pie: Box -->
    <div class="span12">
		 <form class="form-horizontal" id="imageform" method="post" enctype="multipart/form-data" action="ajaximage.php">
				<div class="top-bar" style="padding-left: 0px;">
					<ul class="tab-container">
					  <li class="active"><a href="#tab-home"><i class="icon-user"></i> ข้อมูลส่วนตัว</a></li>
					  <li class=""><a href="#tab-messages"><i class="icon-home"></i> ที่อยู่ปัจจุบัน</a></li>
					  <li><a href="#tab-map"><i class="icon-picture"></i> แผนที่</a></li>
					
					  <li><a href="#tab-settings"><i class="icon-cog"></i> สำหรับเจ้าหน้าที่</a></li>
					    <?php if ($type=="n"){?><?php } ?>
					</ul>
					 <div class='tmp' style='float:right'>
						<?php if ($type=="o") { ?>
						<a href="student.php">
						<?php } else {?>
						<a href="student_assign.php">
						<?php } ?>
						<button class="btn btn-warning" type='button'  id='btnBack'  data-original-title="ย้อนกลับ"  rel="tooltip">กลับ</button></a>
						<a href="#"><button class="btn btn-info" type='submit'  id='btnSave'  data-original-title="บันทึกข้อมูล"  rel="tooltip">บันทึก</button></a>
					</div>
				</div>
    
					<div class="well no-padding tab-content">
					  <div class="tab-pane active" id="tab-home">
							<!-- Create Account: Form Name -->
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> ชื่อ-นามสกุล <span class='medatory'>*</span> </label>
								<div class="controls">
									<input type="text" id="txtThai_name" class="span4 m-wrap" value="<?php echo $val['thai_name'];?>" required maxlength="100" >
									&nbsp;<input type="text" id="txtThai_surname" class="span4 m-wrap" value="<?php echo $val['thai_surname'];?>" required maxlength="100" >
									&nbsp;<input type="text" id="txtThai_nickname" class="span2 m-wrap" value="<?php echo $val['thai_nickname'];?>" maxlength="50" ><span class="help-inline">ไทย</span>
								</div>
								<div class="controls">
									 <input type="text" id="txtEng_name" class="span4 m-wrap" value="<?php echo $val['eng_name'];?>"  maxlength="100" >
									&nbsp;<input type="text" id="txtEng_surname" class="span4 m-wrap" value="<?php echo $val['eng_surname'];?>"  maxlength="100" >
									&nbsp;<input type="text" id="txtEng_nickname" class="span2 m-wrap" value="<?php echo $val['eng_nickname'];?>"  maxlength="50" ><span class="help-inline">อังกฤษ</span>
								</div>
							</div>
							<!-- / Create Account: Form Name -->
							<!-- Create Account: Form Gender -->
							<div class="control-group">
								<label class="control-label" for="inputGender"><i class="icon-user"></i> เพศ</label>
								<div class="controls">
									<div class='row-fluid'>
										<div class="span1">
											<label class="radio line" style="padding-top:5px;">
												<div class="checker"><span><input type="radio" name="rdoSex" value="F" <?php if($val['sex']=='F') echo "checked";?>></span></div> หญิง
											</label>
										</div>
										<div class="span1">
											<label class="radio line" style="padding-top:5px;">
												<div class="checker"><span><input type="radio" name="rdoSex" value="M" <?php if($val['sex']=='M') echo "checked";?>></span></div> ชาย
											</label>
										</div> 
										&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;">&nbsp; วันเกิด <span class='medatory'>*</span> </span>
									 <div class="input-append date btndate"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy" data-date-viewmode="2" data-date-minViewMode="0">
                                        <input class="span1" style="width:100px !important;" id='txtBirthDate' value="<?php echo $val['birth_day'];?>" required size="16" type="text"  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
									 
									<input type="text" id="txtAge" class="span1 m-wrap" readonly value="<?php echo $val['age'];?>"/><span class="help-inline">ปี</span>
									<input type="text" id="txtAgeMonth" class="span1 m-wrap" readonly value="<?php echo $val['age_month'];?>"/><span class="help-inline">เดือน</span>
									</div>
								</div>
								
							</div>
							<!-- / Create Account: Form Gender -->
							<!-- Create Account: Form Username -->
							<div class="control-group">
								<label class="control-label" for="inputAge"><i class="icon-user"></i> ศาสนา </label>
								<div class="controls">
									<input type="text" id="txtReligion" class="span2 m-wrap" value="<?php echo $val['religion'];?>" maxlength="60" >&nbsp;
									&nbsp;&nbsp;&nbsp;&nbsp; <span class="help-inline" style="font-weight:bold;">เชื้อชาติ&nbsp;&nbsp;</span>
									<input type="text" id="txtRace" class="span2 m-wrap" value="<?php echo $val['race'];?>" maxlength="60">&nbsp;
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">สัญชาติ&nbsp;&nbsp; </span>
									<input type="text" id="txtNationality" class="span2 m-wrap" value="<?php echo $val['nationality'];?>" maxlength="60">
								</div>
							</div>
							<!-- / Create Account: Form Username -->
							<div class="alert alert-success" style='margin-top:10px;margin-bottom:10px;margin-left:5px;margin-right:5px;'>
								<i class="icon icon-check"></i> <b>ข้อมูลบิดา - มารดา</b> 
							</div>
							<!-- Create Account: Form Nationality -->
							<div class="control-group">
								<label class="control-label" for="inputstatus"><i class="icon-user"></i> สถานภาพ</label>
								<div class="controls">
									<div class='row-fluid'>
											<div class="span2" style="width:100px !important;">
												<label class="radio line" style="padding-top:5px;">
													<div class="checker"><span><input type="radio" name="rdoParentStatus" value="M" <?php if($val['parent_status']=='M') echo "checked";?>></span></div> อยู่ร่วมกัน
													
												</label>
											</div>
											<div class="span2" style="width:100px !important;">
												<label class="radio line" style="padding-top:5px;">
													<div class="checker"><span><input type="radio" name="rdoParentStatus" value="D" <?php if($val['parent_status']=='D') echo "checked";?>></span></div> หย่าร้าง
												</label>
											</div> 
											<div class="span2" style="width:100px !important;">
												<label class="radio line" style="padding-top:5px;">
													<div class="checker"><span><input type="radio" name="rdoParentStatus" value="O" <?php if($val['parent_status']=='O') echo "checked";?>></span></div> อื่นๆ ระบุ
												</label>
											</div> 
											<input type="text" id="txtOtherParentStatus" class="span6 m-wrap" maxlength="200"  value="<?php echo $val['parent_status_remak'];?>">
									</div>
									 
								</div>
								
							</div>
							<!-- / Create Account: Form Nationality -->
				  
						 
							<!-- Create Account: Form Father -->
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> ชื่อบิดา <span class='medatory'>*</span></label>
								<div class="controls">
									<input type="text" id="txtFather_name" required class="span3 m-wrap" value="<?php echo $val['father_name'];?>" maxlength="100" >&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;" required>นามสกุล<span class='medatory'>*</span></span>
									&nbsp;&nbsp;&nbsp;<input type="text" id="txtFather_surname" required class="span3 m-wrap" value="<?php echo $val['father_surname'];?>" maxlength="100">
									&nbsp;&nbsp;<input type="text" id="txtFather_age" name='number' class="span1" value="<?php echo $val['father_age'];?>" maxlength="2"><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;">การศึกษา</span>&nbsp;
									<input type="text" id='txtFather_education' class="span3" value="<?php echo $val['father_education'];?>" maxlength="80"> 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> อาชีพ </label>
								<div class="controls">
									<input type="text" id="txtFather_occupation" maxlength="120" class="span3 m-wrap" value="<?php echo $val['father_education'];?>" />
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">ตำแหน่ง &nbsp;</span>
									&nbsp;&nbsp;&nbsp;<input type="text" id="txtFather_position"  class="span3 m-wrap" value="<?php echo $val['father_position'];?>"  maxlength="150" />
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">&nbsp;ชื่อสำนักงาน&nbsp;</span>&nbsp;
									<input type="text" class="span4" id="txtFather_company"  value="<?php echo $val['father_company'];?>"  maxlength="150" /> 
								</div>
							 
							</div>
											
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> รายละเอียด </label>
								<div class="controls">
									  <input type="text" id="txtFather_occupation_info"  class="span12 m-wrap" maxlength="200" value="<?php echo $val['father_occupation_info'];?>"/>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> ที่อยู่ที่ทำงาน </label>
								<div class="controls">
									  <input type="text" id="txtFather_company_address" maxlength="200"  class="span12 m-wrap" value="<?php echo $val['father_company_address'];?>" />
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> จังหวัด </label>
								<div class="controls">
									<input type="text"   maxlength="100" class="span2 m-wrap" id="txtFather_province" value="<?php echo $val['father_province'];?>">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">รหัสไปรษณีย์</span>
									&nbsp;<input type="text" id="txtFather_zipcode"  name='number' class="span2 m-wrap" value="<?php echo $val['father_zipcode'];?>" maxlength="5"/>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">โทรศัพท์</span>
									&nbsp;<input type="text" id="txtFather_tele" name='number' class="span2" value="<?php echo $val['father_tele'];?>" maxlength="20"/> 
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">โทรสาร (FAX)</span>
									&nbsp;<input type="text" id="txtFather_fax" name='number' class="span2" value="<?php echo $val['father_fax'];?>" maxlength="20" />
								</div>
							 
							</div>
							
							<!-- / Create Account: Form Father -->

						  <!-- Create Account: Form Monther -->
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> ชื่อมารดา <span class='medatory'>*</span></label>
								<div class="controls">
									<input type="text" id="txtMather_name" required class="span3 m-wrap" value="<?php echo $val['mather_name'];?>" maxlength="100">&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;">นามสกุล<span class='medatory'>*</span></span>
									&nbsp;&nbsp;&nbsp;<input type="text" required id="txtMather_surname" required class="span3 m-wrap" value="<?php echo $val['mather_surname'];?>" maxlength="100">
									&nbsp;&nbsp;<input type="text" id="txtMather_age" class="span1 txtamt" name='number' value="<?php echo $val['mather_age'];?>" maxlength="2"><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">การศึกษา</span>&nbsp;
									<input type="text" id='txtMather_education' class="span3" value="<?php echo $val['mather_education'];?>" maxlength="150">  
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> อาชีพ </label>
								<div class="controls">
									<input type="text" id="txtMather_occupation" maxlength="120" class="span3 m-wrap" value="<?php echo $val['mather_occupation'];?>" />
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">ตำแหน่ง &nbsp;</span>
									&nbsp;&nbsp;&nbsp;<input type="text" id="txtMather_position"  class="span3 m-wrap" value="<?php echo $val['mather_position'];?>"  maxlength="150"/>
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">&nbsp;ชื่อสำนักงาน&nbsp;</span>
									&nbsp;<input type="text" class="span4" id="txtMather_company" value="<?php echo $val['mather_company'];?>"  maxlength="150"/>
								</div>
							 
							</div>
							
							 <div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> รายละเอียด </label>
								<div class="controls">
									  <input type="text"  class="span12 m-wrap" id="txtMather_detail" maxlength="200"  value="<?php echo $val['mather_occupation_info'];?>" />
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> ที่อยู่ที่ทำงาน </label>
								<div class="controls">
									  <input type="text"  class="span12 m-wrap" id="txtMather_company_address" value="<?php echo $val['mather_company_adress'];?>" maxlength="200"/>
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-user"></i> จังหวัด </label>
								<div class="controls">
									<input type="text" maxlength="100" id="txtMather_province" class="span2 m-wrap" value="<?php echo $val['mather_province'];?>">
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">รหัสไปรษณีย์</span>
									&nbsp;<input type="text" maxlength="5"  name='number' id="txtMather_zipcode" class="span2 m-wrap" value="<?php echo $val['mather_zipcode'];?>"/>
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">โทรศัพท์</span>
									&nbsp;<input type="text" name='number' maxlength="20" id='txtMather_tele' class="span2" value="<?php echo $val['mather_tele'];?>"/> 
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">โทรสาร (FAX)</span>
									&nbsp;<input type="text" name='number' maxlength="20" id='txtMather_fax' class="span2" value="<?php echo $val['mather_fax'];?>" /> &nbsp;&nbsp; 
								</div>
							 
							</div>
							
					 
		 			</div>
					  
					  <div class="tab-pane" id="tab-messages">
						 <div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> ที่อยู่ปัจจุบัน <span class='medatory'>*</span></label>
								<div class="controls">
									<input type="text" id='txtAddress' required maxlength="200" class="span12 m-wrap" value="<?php echo $val['address'];?>" />
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> จังหวัด <span class='medatory'>*</span></label>
								<div class="controls">
									&nbsp;<input type="text" maxlength="100" required id='txtProvince' class="span3 m-wrap" value="<?php echo $val['privince'];?>"/>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">รหัสไปรษณีย์</span>
									&nbsp;<input type="text" maxlength="5" name='number' id='txtZipcode' class="span3 m-wrap" value="<?php echo $val['zipcode'];?>"/>
								 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> โทรศัพท์มือถือ <span class='medatory'>*</span></label>
								<div class="controls">
									&nbsp;<input type="text" id='txtMobilephone' name='number' maxlength="20" required class="span2 m-wrap" value="<?php echo $val['mobilephone'];?>" />
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">โทรศัพท์บ้าน  </span>
									&nbsp;<input type="text" id='txtTelephone' name='number' maxlength="20" class="span2 m-wrap" value="<?php echo $val['telephone'];?>"/>
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">Email</span>
									&nbsp;<input type="text" id='txtEmail'  maxlength="60"   class="span3 m-wrap" value="<?php echo $val['email'];?>"/>
								</div>
							 
							</div>
								<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> เบอร์โทรผู้ปกครอง <span class='medatory'>*</span></label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" id='txtTelephone_Parent1' name='number' maxlength="20" required class="span2 m-wrap" value="<?php echo $val['tele_parent_1'];?>" />
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">เบอร์โทร 2  </span>
									&nbsp;<input type="text" id='txtTelephone_Parent2' name='number' maxlength="20" class="span2 m-wrap" value="<?php echo $val['tele_parent_2'];?>" />
									&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;">เบอร์โทร 3</span>
									&nbsp;<input type="text" id='txtTelephone_Parent3'  maxlength="20"   class="span2 m-wrap" value="<?php echo $val['tele_parent_3'];?>" />
								 
								</div>
							 
							</div>
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> ติดต่อฉุกเฉิน <span class='medatory'>*</span></label>
								<div class="controls">
									<input type="text" required id='txtContact'  maxlength="150" class="span12 m-wrap" value="<?php echo $val['emergency_contact'];?>"/>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> นักเรียนมีพี่ </label>
								<div class="controls">
									<input type="text" id='txtNo_of_brother1' name='number' maxlength="2" class="span2 m-wrap" value="<?php echo $val['no_of_brother1'];?>" /><span class="help-inline">คน</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 1.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_1' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_1'];?>"  /><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 2.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_2' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_2'];?>"  /><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 3.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_3' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_3'];?>"  /><span class="help-inline">ปี</span>
								 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> นักเรียนมีน้อง</label>
								<div class="controls">
									<input type="text" id='txtNo_of_brother2' name='number' maxlength="2" class="span2 m-wrap" value="<?php echo $val['no_of_brother2'];?>" /><span class="help-inline">คน</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 1.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_4' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_4'];?>"/><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 2.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_5' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_5'];?>"/><span class="help-inline">ปี</span>
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> 3.อายุ</span>
									&nbsp;<input type="text" id='txtBrother_6' name='number' maxlength="2" class="span1 m-wrap" value="<?php echo $val['brother_6'];?>"/><span class="help-inline">ปี</span>
								 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> กรุ๊ปเลือด</label>
								<div class="controls">
									<input type="text" id='txtBlood'  maxlength="2" class="span2 m-wrap" value="<?php echo $val['blood'];?>" /> 
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> แพ้อาหาร</span>
									&nbsp;<input type="text"  class="span4 m-wrap" maxlength="100"  id='txtFood_allergies' value="<?php echo $val['food_allergies'];?>" /> 
									&nbsp;&nbsp;&nbsp;&nbsp;<span class="help-inline" style="font-weight:bold;"> แพ้ยา</span>
									&nbsp;<input type="text"  class="span4 m-wrap" maxlength="100" id='txtBe_allergic' value="<?php echo $val['be_allergic'];?>" />  
								 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> โรคประจำตัว</label>
								<div class="controls">
									<input type="text"  maxlength="200"  id='txtCongenital_disease' class="span12 m-wrap" value="<?php echo $val['congenital_disease'];?>" /> 
								 
								</div>
							 
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-home"></i> อุปนิสัยพิเศษ</label>
								<div class="controls">
									<input type="text" maxlength="200" id='txtSpecial_character' class="span12 m-wrap" value="<?php echo $val['special_character'];?>" /> 
								 
								</div>
							 
							</div>
					 </div>
					   <div class="tab-pane" id="tab-map" style='min-height:350px;'>
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> แผนที่ </label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<div class="input-append">
									<input class="span12 no-margin btn text-right" name="photoimg" id="photoimg" type="file">
								</div>
								</div>
							</div>
							 
								<div class="image-display text-center" id="imgMap">  
									<?php if ($val['map'] != "") {
										$_SESSION['Photo'] = $val['map'];
									?>
									<img src="<?php echo $val['map'];?>"   class="img-polaroid" />
									<?php }else {?>
									<img src="img/no-image.png"   class="img-polaroid" />
									<?php } ?>
								</div>
						  
						</div>
					  <div class="tab-pane" id="tab-settings">
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> อุปกรณ์การเรียน &nbsp;<span class='medatory'>*</span></label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<select class="no-margin" <?php echo $disable;?> id='cboAssest' style="width:150px !important;">
									</select>
									<span class="help-inline" style="">บาท</span>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;">ค่าธรรมเนียมการเรียน&nbsp;<span class='medatory'>*</span>&nbsp;</span>
									<select class="no-margin" <?php echo $disable;?> id='cboTerm' style="width:150px !important;">
									</select>
									<span class="help-inline" >บาท</span>
								</div>
							</div>
						 
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> ค่าใช้จ่ายอื่น ๆ 1 </label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="text" <?php echo $disable;?> name='number' maxlength="7"  id='txtOtherpay1' class="span2 m-wrap text-right" value="<?php echo $val['free_other1'];?>"/>
									<span class="help-inline">บาท</span>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<span class="help-inline" style="font-weight:bold;">&nbsp;ค่าใช้จ่ายอื่น ๆ 2&nbsp;</span>
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="text" <?php echo $disable;?> id='txtOtherpay2'  name='number' maxlength="7" class="span2 m-wrap text-right" value="<?php echo $val['free_other2'];?>"/>
									<span class="help-inline">บาท</span>
								</div>
							</div>
							
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> ใช้บริการรถโรงเรียน </label>
								<div class="controls" style='padding-left:50px !important;'> 
									<div class='row-fluid'>
										 
										<div class="span1">
											<label class="radio line" style="padding-top:5px;">
												
												<div class="checker">
													<span>
														<input type="radio" name="rdoBus" <?php echo $disable;?> value="N" <?php if($val['bus']=='N') echo "checked";?>>
													</span>
												</div> ไม่ใช้
											</label>
										</div>
										<div class="span1">
											<label class="radio line" style="padding-top:5px;">
												<div class="checker"><span><input type="radio" <?php echo $disable;?> name="rdoBus" value="Y" <?php if($val['bus']=='Y') echo "checked";?>></span></div> ใช้
											</label>
										</div> 
									
									 <input type="text" name="number" id="txtBus_fee" <?php echo $disable;?> class="span1 m-wrap text-right" maxlength="4" value="<?php echo $val['bus_payment'];?>" />
									 <span class="help-inline">บาท</span>
									 &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									  <span class="help-inline" style="font-weight:bold;">ค่าชุดนักเรียน</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									  <input type="text" name='number' <?php echo $disable;?> id="txtStudent_form_fee" maxlength="7" class="span2 m-wrap text-right" style='width:150px !important;' value="<?php echo $val['free_student_form'];?>" />
									  <span class="help-inline">บาท</span>
									</div>
									
								</div>
							</div>
							
							 
							 <div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> รายการชำระครั้งแรก </label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<input type="text" id='txtTotal' class="span2 m-wrap text-right" value="<?php echo $val['Total'];?>" placeholder="0" style='background-color:#f7e8d4;' disabled />
									<span class="help-inline" style="font-weight:bold;">บาท</span>
								</div>
							</div>
							
						
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> ชั้นปีที่มอบตัว </label>
								<div class="controls">
									&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
									<select class="no-margin span8" id="cboClass" <?php echo $disable;?> style="width:300px !important;">
									</select>
								 <span class="help-inline" style="font-weight:bold;margin-left:50px;">วันที่มอบตัว</span>
								 <div class="input-append date btndate"   data-date="12-02-2012"  data-date-format="dd/mm/yyyy" data-date-viewmode="0" data-date-minViewMode="0">
                                        <input class="span1" style="width:100px !important;" id='txtRegisterDate' required size="16" type="text" value='<?php echo $val['registerdate'];?>'  readonly="">
                                        <span class="add-on"><i class="icon-calendar"></i></span>
                                    </div>
								</div>
							</div>
							 
							<div class="control-group">
								<label class="control-label" for="inputName"><i class="icon-caret-right"></i> ผู้แนะนำ </label>
								<div class="controls">
								&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
								<input type="text" maxlength="100" <?php echo $disable;?> id='txtRecommance' class="span4 m-wrap" value="<?php echo $val['suggessted'];?>" /> 
								</div>
							</div>
							<div class="control-group">
							<label class="control-label"><i class="icon-caret-right"></i>เอกสาร</label>
							<div class="controls">
							 <div class="row-fluid">
									<div class="span3">
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_address' id='doc_address' <?php echo $disable;?>  value="Y"  <?php if($val['doc_address']=='Y') echo "checked";?> ></span></div> สำเนาทะเบียนบ้านเด็กและผู้ปกครอง
										</label>
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_idcard' id='doc_idcard' <?php echo $disable;?> value="Y" <?php if($val['doc_idcard']=='Y') echo "checked";?> ></span></div> สำเนาบัตรประชาชน
										</label>
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_birth' id='doc_birth' <?php echo $disable;?> value="Y" <?php if($val['doc_birth']=='Y') echo "checked";?> ></span></div> สำเนาสูติบัตร
										</label>
									</div>
									<div class="span3">
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_healty' id='doc_healty' <?php echo $disable;?> value="Y" <?php if($val['doc_healty']=='Y') echo "checked";?> ></span></div> สำเนาสุขภาพเด็ก
										</label>
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_pic_chident' id='doc_pic_chident' <?php echo $disable;?> value="Y" <?php if($val['doc_pic_chident']=='Y') echo "checked";?> ></span></div> รูปถ่ายเด็ก 4 รูป ขนาด 1"
										</label>
										<label class="checkbox line">
										<div class="checker"><span><input type="checkbox" name='doc_pic_parent' id='doc_pic_parent' <?php echo $disable;?> value="Y" <?php if($val['doc_pic_parent']=='Y') echo "checked";?> ></span></div> รูปถ่ายผู้ปกครอง 3 ท่านขนาด 1"
										</label>
									</div>
								</div>
							</div>
						</div>
						
					  </div>
					 
					</div>

			 </form>	 
    </div>
    <!-- / Pie -->

</div>
<!-- / Live Stats -->

<?php
echo footerHTML();
?>

<!-- Javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src='js/jquery.hotkeys.js'></script>
<!--script src='js/fullcalendar.min.js'></script-->
<script src="js/jquery-ui-1.10.2.custom.min.js"></script>
<script src="js/jquery.pajinate.js"></script>
<!--script src="js/jquery.prism.min.js"></script-->
<script src="js/jquery.dataTables.min.js"></script>

<script src="js/jquery.flot.resize.js"></script>
<script src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-wysiwyg.js"></script>
<!--script src="js/bootstrap-typeahead.js"></script-->
<script src="js/jquery.easing.min.js"></script>
<script src="js/jquery.chosen.min.js"></script>
<script src="js/avocado-custom.js"></script>
<script src="js/jqBootstrapValidation.js"></script>
<script src="js/bootstrap-datepicker.js"></script>

<script src="js/jquery.form.js"></script>
<script>
    $(function() {
		var type="<?php echo $_POST['my_t'];?>";
		var s_id =<?php echo $_POST['my'];?>;
		var ar;
		 var url='controls/student_register_model.php';
		var cdt = new Date();  
		var current_year =cdt.getFullYear();
		
         $('#photoimg').live('change', function() {
		   $("#imgMap").html('');
            $("#imgMap").html('<img src="img/ajax-loader2.gif" width="220px" height="19px" alt="Uploading..."/>');
            $("#imageform").ajaxForm({
                target : '#imgMap'
            }).submit();
        });
		
		var checkDate = $('.btndate').datepicker().on('changeDate', function(ev) {
		//checkDate.hide();
	 
		var _bdate = $("#txtBirthDate").val();
		var str_Split = _bdate.split('/');
 
		$("#txtAge").val(parseInt(current_year) - parseInt(str_Split[2])) ;
 
		}).data('datepicker');
		
		$("#txtOtherParentStatus,#txtBus_fee").attr('disabled','disabled');
		$("input[name=number]").live('keypress',function(e){

			if( e.which!=8 && e.which!=0 && (e.which<48 || e.which>57)){
				return false;
			}
		});
		
		$.get(url, {"m":"class"},function(data){
			var obj=eval('('+data+')');	
			if (obj != null){
				$.each(obj, function(index, text) {
					$("#cboClass").append(
							$('<option></option>').val(text).html(index)
						 );
				});
				$("#cboClass").val(<?php echo $val['init_class'];?>);
			}
	});
	$.get(url, {"m":"term"},function(data){
			var obj=eval('('+data+')');	
			if (obj != null){
				$.each(obj, function(index, text) {
					$("#cboTerm").append(
							$('<option></option>').val(text).html(index)
						 );
				});
			}
			$("#cboTerm").val(<?php echo $val['free_term'];?>)
	});
	$.get(url, {"m":"assets"},function(data){
			var obj=eval('('+data+')');	
			if (obj != null){
				$.each(obj, function(index, text) {
					$("#cboAssest").append(
							$('<option></option>').val(text).html(index)
						 );
				});
			}
			$("#cboAssest").val(<?php echo $val['free_assetment'];?>)
			CalcTotal();
	});
     
	$("#cboAssest,#cboTerm").change(function(){
		CalcTotal();
	});
	 
	$("#txtOtherpay1,#txtOtherpay2,#txtStudent_form_fee,#txtBus_fee").live('keyup',function(e){
		CalcTotal();
	});

	$("input[name='rdoParentStatus']").click(function(){
		if($('input:radio[name=rdoParentStatus]:checked').val() == "O"){
			$("#txtOtherParentStatus").removeAttr('disabled');
			$("#txtOtherParentStatus").focus();
		}else{
			$("#txtOtherParentStatus").attr('disabled','disabled');
		}
	});
	$("input:radio[name='rdoBus']").click(function(){
	 
		if($('input:radio[name=rdoBus]:checked').val() == "Y"){
			$("#txtBus_fee").removeAttr('disabled');
			$("#txtBus_fee").focus();
		}else{
			$("#txtBus_fee").attr('disabled','disabled');
		}
	});
		
	function CalcTotal(){
		var _iasset = parseInt(isNaN($("#cboAssest option:selected").text())?0:$("#cboAssest option:selected").text());
		var _term = parseInt(isNaN($("#cboTerm option:selected").text())?0:$("#cboTerm option:selected").text());
		var _other1= parseInt(isNaN($("#txtOtherpay1").val())?0:$("#txtOtherpay1").val());
		var _other2= parseInt(isNaN($("#txtOtherpay2").val())?0:$("#txtOtherpay2").val());
		var _form = parseInt(isNaN($("#txtStudent_form_fee").val())?0:$("#txtStudent_form_fee").val());
		var _bus = parseInt(isNaN($("#txtBus_fee").val())?0:$("#txtBus_fee").val());
		var _total =  parseInt(_iasset)+ parseInt(_term )+ parseInt(_other1 )+ parseInt(_other2) + parseInt(_form);
		 
		if ($('input:radio[name=rdoBus]:checked').val() == "Y"){
			_total += _bus;
		}
	 
		$("#txtTotal").val(CommaFormatted(_total.toFixed(2)));
		
	}
	
	$("#btnSave").click(function(){
		$("input").not("[type=submit]").jqBootstrapValidation({preventSubmit: false,
			submitSuccess: function ($form, event) { event.preventDefault();}
		}); 
	  
		var _thai_name = $.trim($("#txtThai_name").val());		
		var _thai_surname = $.trim($("#txtThai_surname").val());	
		var _thai_nick_name =$.trim($("#txtThai_nickname").val());
		
		var _name = $.trim($("#txtEng_name").val());	
		var _surname = $.trim($("#txtEng_surname").val());
		var _nickname = $.trim($("#txtEng_nickname").val());		
		var _sex = $("input:radio[name=rdoSex]:checked").val();
		var _birthdate = $("#txtBirthDate").val();
		 
		if (type == "n"){
			var _term = $("#cboTerm").val();
			var _assets= $("#cboAssest").val();
			var _class = $("#cboClass").val();
		}
		
		if (_thai_name.length !=0 && _thai_surname.length !=0 ){
			
			ar={"thai_name":_thai_name
				, "thai_surname":_thai_surname 
				, "thai_nickname":_thai_nick_name
				, "eng_name":_name
				, "eng_surname":_surname
				, "eng_nickname":_nickname
				, "sex":_sex
				, "birthdate":_birthdate

				,'religion':$("#txtReligion").val()
				,'race':$("#txtRace").val()
				,'nationality':$("#txtNationality").val()
				,'parent_status':$("input:radio[name=rdoParentStatus]").val()
				,'parent_status_remak':$("#txtOtherParentStatus").val()
				,'father_name':$("#txtFather_name").val()
				,'father_surname':$("#txtFather_surname").val()
				,'father_age':$("#txtFather_age").val()
				,'father_education':$("#txtFather_education").val()
				,'father_occupation':$("#txtFather_occupation").val()
				,'father_occupation_info':$("#txtFather_occupation_info").val()
				,'father_position':$("#txtFather_position").val()
				,'father_company':$("#txtFather_company").val()
				,'father_company_address':$("#txtFather_company_address").val()
				,'father_province':$("#txtFather_province").val()
				,'father_zipcode':$("#txtFather_zipcode").val()
				,'father_tele':$("#txtFather_tele").val()
				,'father_fax':$("#txtFather_fax").val()
				,'mather_name':$("#txtMather_name").val()
				,'mather_surname':$("#txtMather_surname").val()
				,'mather_age':$("#txtMather_age").val()
				,'mather_education':$("#txtMather_education").val()
				,'mather_position':$("#txtMather_position").val()
				,'mather_occupation':$("#txtMather_occupation").val()
				,'mather_occupation_info':$("#txtMather_detail").val()
				,'mather_company':$("#txtMather_company").val()
				,'mather_company_adress':$("#txtMather_company_address").val()
				,'mather_province':$("#txtMather_province").val()
				,'mather_zipcode':$("#txtMather_zipcode").val()
				,'mather_tele':$("#txtMather_tele").val()
				,'mather_fax':$("#txtMather_fax").val()
			
				,'address':$("#txtAddress").val()
				,'privince':$("#txtProvince").val()
				,'zipcode':$("#txtZipcode").val()
				,'telephone':$("#txtTelephone").val()
				,'mobilephone':$("#txtMobilephone").val()
				,'email':$("#txtEmail").val() || ''
				
				,'emergency_contact':$("#txtContact").val()
				,'no_of_brother1':$("#txtNo_of_brother1").val() || '0'
				,'brother_1':$("#txtBrother_1").val() || '0'
				,'brother_2':$("#txtBrother_2").val() || '0'
				,'brother_3':$("#txtBrother_3").val() || '0'
				,'no_of_brother2':$("#txtNo_of_brother2").val() || '0'
				,'brother_4':$("#txtBrother_4").val() || '0'
				,'brother_5':$("#txtBrother_5").val() || '0'
				,'brother_6':$("#txtBrother_6").val() || '0'
				
				,'blood':$("#txtBlood").val()
				,'food_allergies':$("#txtFood_allergies").val()
				,'be_allergic':$("#txtBe_allergic").val()
				
				,'congenital_disease':$("#txtCongenital_disease").val()
				,'special_character':$("#txtSpecial_character").val()
				<?php if ($_POST['my_t']=="n"){?>		
				, 'free_term':_term
				, 'free_assetment':_assets
				, 'init_class':_class				
				,'free_other1':$("#txtOtherpay1").val() || '0'
				,'free_other2':$("#txtOtherpay2").val() || '0'
				,'registerdate':$("#txtRegisterDate").val()
				,'bus':$('input:radio[name=rdoBus]:checked').val()
				,'bus_payment': $("#txtBus_fee").val()  
				,'free_student_form': $("#txtStudent_form_fee").val()
				,'suggessted': $("#txtRecommance").val()
				,'doc_idcard': $("input[name=doc_idcard]:checked").val()=='Y'?'Y':'N'
				,'doc_address':$("input[name=doc_address]:checked").val()=='Y'?'Y':'N'
				,'doc_birth': $("input[name=doc_birth]:checked").val()=='Y'?'Y':'N'
				,'doc_pic_chident': $("input[name=doc_pic_chident]:checked").val()=='Y'?'Y':'N'  
				,'doc_pic_parent':$("input[name=doc_pic_parent]:checked").val()=='Y'?'Y':'N'
				,'doc_healty': $("input[name=doc_healty]:checked").val()=='Y'?'Y':'N'
				<?php } ?>
				};
			
			$("#popupSave").modal('show');
		}
		
		 $("input").jqBootstrapValidation("destroy");
	});		
	$("#btnConfirm").click(function(){
		$.ajax({
				type: 'POST',
				cache: false,
				url: 'controls/student_register_model.php',
				data: {"m":"save","info":ar,"id":s_id,"type":"<?php echo $_POST['my_t'];?>"},
				success: function(data){
					//alert(data);
					$("#popupSave").modal('hide');
					alert('บันทึกข้อมูลเรียบร้อย');
					$("#btnBack").click(); //will set it  
				}
			});
	});
	function CommaFormatted(amount){
		 
			var delimiter = ","; // replace comma if desired
			var a = amount.split('.',2)
			var d = a[1];
			var i = parseInt(a[0]);
			if(isNaN(i)) { return ''; }
			var minus = '';
			if(i < 0) { minus = '-'; }
			i = Math.abs(i);
			var n = new String(i);
			var a = [];
			while(n.length > 3)
			{
				var nn = n.substr(n.length-3);
				a.unshift(nn);
				n = n.substr(0,n.length-3);
			}
			if(n.length > 0) { a.unshift(n); }
			n = a.join(delimiter);
			if(d.length < 1) { amount = n; }
			else { amount = n + '.' + d; }
			amount = minus + amount;
			return amount;
	}
	
	$("#btnBack").click(function(){
		if (type=='o'){
		
			$("#imageform").get(0).setAttribute('action', 'student.php');
			$("#imageform").submit();
		}else {
			$("#imageform").get(0).setAttribute('action', 'student_assign.php');
			$("#imageform").submit();
		}
	});
	
});
</script>
</html>